﻿using System.Linq;
using Appetite.Data.EntityFramework.Repository;
using Appetite.Domain.Models;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Appetite.Integration.Tests.Repository
{
    [TestClass]
    public class RecipeRepositoryTest
    {
        [TestMethod]
        public void Insert_ShouldStoreEntity()
        {
            RecipeRepository recipeRepository = new RecipeRepository();
            Recipe recipe = new Recipe();
            recipe.Description = "abc";
            recipe.RecipeCategoryId = new RecipeCategoryRepository().All.First().Id;
            recipe.TimeInMinutes = 40;
            recipe.Title = "Title";

            recipeRepository.InsertOrUpdate(recipe);
            recipeRepository.Save();

            Recipe savedRecipe = recipeRepository.Find(recipe.Id);

            Assert.IsNotNull(savedRecipe);
        }
    }
}